home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / c / dicepj20.lha / diceproject / sources / options.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-09  |  25.2 KB  |  969 lines

  1.  
  2. #include <exec/types.h>
  3. #include <libraries/asl.h>
  4. #include <intuition/intuition.h>
  5. #include <intuition/gadgetclass.h>
  6. #include <graphics/displayinfo.h>
  7. #include <graphics/gfxbase.h>
  8.  
  9. #include <clib/gadtools_protos.h>
  10. #include <clib/iffparse_protos.h>
  11. #include <clib/asl_protos.h>
  12. #include <clib/exec_protos.h>
  13. #include <clib/alib_protos.h>
  14. #include <clib/graphics_protos.h>
  15. #include <clib/utility_protos.h>
  16. #include <clib/intuition_protos.h>
  17.  
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <ctype.h>
  21.  
  22. #define CATCOMP_NUMBERS
  23.  
  24. #include "project.catalog.h"
  25.  
  26. #include "compiler.h"
  27.  
  28. #include "project.h"
  29.  
  30. extern AttachList( void );
  31. extern DettachList( void );
  32. extern struct TagItem *ScreenPrefs( struct TagItem * );
  33. extern void StdVanillaKey( long code );
  34. extern void LoadScreenTags( struct IFFHandle * );
  35. extern void SaveScreenTags( struct IFFHandle * );
  36.  
  37. extern struct TagItem *CheckTag;
  38.  
  39. struct CompilerOpts Config = {
  40.     CPU30,FPU82,
  41.     SMALL,SMALL,
  42.     FALSE,
  43.     FALSE,
  44.     FALSE,
  45.     FALSE,
  46.     FALSE,
  47.     FALSE,
  48.     REGARG,
  49.     FALSE,
  50.     0,
  51.     TRUE,
  52.     TRUE,
  53.     PROF0,
  54.     0,
  55.     0,
  56.     0,
  57.     "2.0",
  58. };
  59.  
  60. char *OptLine;
  61. char *ParmsLine;
  62.  
  63. char *DICEDir;
  64. char *AutoDir;
  65. char *SourceDir;
  66. char *DestDir;
  67. char *IncludeDir;
  68. char *LibDir;
  69. char *ObjDir;
  70. char *Editor;
  71.  
  72. BOOL compilall=FALSE,compil=FALSE,link=FALSE;
  73.  
  74. struct CompilerOpts Config2;
  75.  
  76. void MakeOptions( void ) {
  77.   char temp[102];
  78.  
  79.     strcpy( temp , "-" );
  80.     strncat( temp , Config.Version , 3 );
  81.     if ( Config.Proto )
  82.     strcat( temp , " -proto" );
  83.     switch( Config.CPU ) {
  84.       case 1:
  85.     strcat( temp , " -020" );
  86.     break;
  87.       case 2:
  88.     strcat( temp , " -030" );
  89.     break;
  90.     }
  91.     switch( Config.FPU ) {
  92.       case 1:
  93.     strcat( temp , " -881" );
  94.     break;
  95.       case 2:
  96.     strcat( temp , " -882" );
  97.     break;
  98.     }
  99.     switch( Config.Prof ) {
  100.       case 1:
  101.     strcat( temp , " -prof" );
  102.     break;
  103.       case 2:
  104.     strcat( temp , " -prof2" );
  105.     break;
  106.     }
  107.     if ( Config.CPP )
  108.     strcat( temp , " -//" );
  109.     if ( Config.Data == SMALL )
  110.     strcat( temp , " -md" );
  111.     else
  112.     strcat( temp , " -mD" );
  113.     if ( Config.Code == SMALL )
  114.     strcat( temp , " -mc" );
  115.     else
  116.     strcat( temp , " -mC" );
  117.     if ( Config.RCalls == REGARG )
  118.     strcat( temp , " -mRR" );
  119.     if ( Config.ICalls )
  120.     strcat( temp , " -mi" );
  121.     if ( Config.Resident && !Config.Hunk )
  122.     strcat( temp , " -r" );
  123.     if ( Config.DStack )
  124.     strcat( temp , " -gs" );
  125.     if ( Config.Chip )
  126.     strcat( temp , " -chip" );
  127.     if ( Config.Frag )
  128.     strcat( temp , " -frag" );
  129.     if ( Config.Unix )
  130.     strcat( temp , " -unix" );
  131.     if ( Config.Hunk ) {
  132.     if ( Config.Resident )
  133.         strcat( temp , " -pr" );
  134.     else
  135.         strcat( temp , " -pi" );
  136.     }
  137.     if ( Config.DebugI )
  138.     strcat( temp , " -s" );
  139.     if ( Config.DebugL )
  140.     strcat( temp , " -d1" );
  141.     switch( Config.HunkCode ) {
  142.       case 1:
  143.     strcat( temp , " -ms" );
  144.     break;
  145.       case 2:
  146.     strcat( temp , " -ms2" );
  147.     break;
  148.     }
  149.     ReplaceChar( &OptLine , temp );
  150. }
  151.  
  152.  
  153. /****************************************************************************
  154. ***                                      ***
  155. ***    Actions des boutons de la fenêtre DirSet              ***
  156. ***                                      ***
  157. ****************************************************************************/
  158.  
  159. char *SSource,*SDest,*SInclude,*SLib,*SObj,*SDICE,*SEdit;
  160.  
  161. void ProjectCloseDirSet( BOOL use ) {
  162.     if ( DirSetWnd ) {
  163.     RemWinC( DirSetWnd );
  164.     CloseDirSetWindow( );
  165.     if ( !use ) {
  166.         ReplaceChar( &SourceDir , SSource );
  167.         ReplaceChar( &DestDir , SDest );
  168.         ReplaceChar( &IncludeDir , SInclude );
  169.         ReplaceChar( &LibDir , SLib );
  170.         ReplaceChar( &ObjDir , SObj );
  171.         ReplaceChar( &DICEDir , SDICE );
  172.         ReplaceChar( &Editor , SEdit );
  173.     } else {
  174.         if ( strcmp( SSource , SourceDir ) || strcmp( SDest , DestDir ) ||
  175.             strcmp( SInclude , IncludeDir ) || strcmp( SLib , LibDir ) ||
  176.             strcmp( SEdit , Editor ) ||
  177.             strcmp( SObj , ObjDir ) || strcmp( SDICE , DICEDir ) )
  178.         {
  179.         saved = FALSE;
  180.         RemoveAssign( );
  181.         MakeAssign( );
  182.         UpdateNameList( );
  183.         }
  184.     }
  185.     free( SSource );
  186.     free( SDest );
  187.     free( SInclude );
  188.     free( SLib );
  189.     free( SObj );
  190.     free( SDICE );
  191.     free( SEdit );
  192.     }
  193. }
  194.  
  195. int DirSetUseClicked( void ) {
  196.     ProjectCloseDirSet( TRUE );
  197. }
  198.  
  199. int DirSetCancelClicked( void ) {
  200.     ProjectCloseDirSet( FALSE );
  201. }
  202.  
  203. int SourceClicked( void )
  204. {
  205.   struct FileRequester *fr;
  206.   struct ModuleNode *wn=ModuleList->lh_Head;
  207.  
  208.     if (fr = AskDirectory( "Select sources path" , SourceDir )) {
  209.     ReplaceChar( &SourceDir , fr->rf_Dir );
  210.     FreeAslRequest(fr);
  211.     GT_SetGadgetAttrs( DirSetGadgets[6] , DirSetWnd , NULL , GTTX_Text , (long)SourceDir , TAG_DONE );
  212.     }
  213. }
  214.  
  215. int DestClicked( void )
  216. {
  217.   struct FileRequester *fr;
  218.  
  219.     if (fr = AskDirectory( "Select destination path" , DestDir )) {
  220.     ReplaceChar( &DestDir , fr->rf_Dir );
  221.     FreeAslRequest(fr);
  222.     GT_SetGadgetAttrs( DirSetGadgets[7] , DirSetWnd , NULL , GTTX_Text , (long)DestDir , TAG_DONE );
  223.     }
  224. }
  225.  
  226. int IncludeClicked( void )
  227. {
  228.   struct FileRequester *fr;
  229.  
  230.     if (fr = AskDirectory( "Select includes path" , IncludeDir )) {
  231.     ReplaceChar( &IncludeDir , fr->rf_Dir );
  232.     FreeAslRequest(fr);
  233.     GT_SetGadgetAttrs( DirSetGadgets[8] , DirSetWnd , NULL , GTTX_Text , (long)IncludeDir , TAG_DONE );
  234.     }
  235. }
  236.  
  237. int LibClicked( void )
  238. {
  239.   struct FileRequester *fr;
  240.  
  241.     if (fr = AskDirectory( "Select libraries path" , LibDir )) {
  242.     ReplaceChar( &LibDir , fr->rf_Dir );
  243.     FreeAslRequest(fr);
  244.     GT_SetGadgetAttrs( DirSetGadgets[9] , DirSetWnd , NULL , GTTX_Text , (long)LibDir , TAG_DONE );
  245.     }
  246. }
  247.  
  248. int ObjClicked( void )
  249. {
  250.   struct FileRequester *fr;
  251.  
  252.     if (fr = AskDirectory( "Select objects path" , ObjDir )) {
  253.     ReplaceChar( &ObjDir , fr->rf_Dir );
  254.     FreeAslRequest(fr);
  255.     GT_SetGadgetAttrs( DirSetGadgets[10] , DirSetWnd , NULL , GTTX_Text , (long)ObjDir , TAG_DONE );
  256.     }
  257. }
  258.  
  259. int PrgClicked( void )
  260. {
  261.   struct FileRequester *fr;
  262.  
  263.     if (fr = AskDirectory( "Select objects path" , DICEDir )) {
  264.     ChangeDICEDir( fr->rf_Dir );
  265.     FreeAslRequest(fr);
  266.     GT_SetGadgetAttrs( DirSetGadgets[11] , DirSetWnd , NULL , GTTX_Text , (long)DICEDir , TAG_DONE );
  267.     }
  268. }
  269.  
  270. int AutoDocClicked( void )
  271. {
  272.   struct FileRequester *fr;
  273.  
  274.     if (fr = AskDirectory( "Select Autodocs path" , DICEDir )) {
  275.     ReplaceChar( &AutoDir , fr->rf_Dir );
  276.     FreeAslRequest(fr);
  277.     GT_SetGadgetAttrs( DirSetGadgets[13] , DirSetWnd , NULL , GTTX_Text , (long)AutoDir , TAG_DONE );
  278.     }
  279. }
  280.  
  281. /****************************************************************************
  282. ***                                      ***
  283. ***    Action des boutons de la fenêtre d'options de compilation         ***
  284. ***                                      ***
  285. ****************************************************************************/
  286.  
  287. int ProjectCloseCompilerOpt( BOOL use ) {
  288.     if ( CompilerWnd ) {
  289.     if ( use ) {
  290.         if ( memcmp( &Config , &Config2 , sizeof( struct CompilerOpts ) ) ) {
  291.         saved = FALSE;
  292.         compilall = compil = TRUE;
  293.         memcpy( &Config , &Config2 , sizeof( struct CompilerOpts ) );
  294.         MakeOptions( );
  295.         }
  296.     }
  297.     RemWinC( CompilerWnd );
  298.     CloseCompilerWindow( );
  299.     }
  300. }
  301.  
  302. void ProjectCloseLinkerOpt( BOOL use ) {
  303.     if ( LinkerWnd ) {
  304.     RemWinC( LinkerWnd );
  305.     CloseLinkerWindow( );
  306.     if ( use ) {
  307.         if ( memcmp( &Config , &Config2 , sizeof( struct CompilerOpts ) ) ) {
  308.         saved = FALSE;
  309.         link = TRUE;
  310.         memcpy( &Config , &Config2 , sizeof( struct CompilerOpts ) );
  311.         MakeOptions( );
  312.         }
  313.     }
  314.     }
  315. }
  316.  
  317. int CompilerUseClicked( void ) {
  318.     ProjectCloseCompilerOpt( TRUE );
  319. }
  320.  
  321. int CompilerCancelClicked( void ) {
  322.     ProjectCloseCompilerOpt( FALSE );
  323. }
  324.  
  325. int LinkerUseClicked( void ) {
  326.     ProjectCloseLinkerOpt( TRUE );
  327. }
  328.  
  329. int LinkerCancelClicked( void ) {
  330.     ProjectCloseLinkerOpt( FALSE );
  331. }
  332.  
  333. int RelocHunkClicked( void )
  334. {
  335.     if ( LinkerGadgets[3]->Flags & GFLG_SELECTED )
  336.     Config2.Hunk = TRUE;
  337.     else
  338.     Config2.Hunk = FALSE;
  339. }
  340.  
  341. int ResidentClicked( void )
  342. {
  343.     if ( CompilerGadgets[9]->Flags & GFLG_SELECTED )
  344.     Config2.Resident = TRUE;
  345.     else
  346.     Config2.Resident = FALSE;
  347. }
  348.  
  349. int DebugIClicked( void )
  350. {
  351.     if ( LinkerGadgets[4]->Flags & GFLG_SELECTED )
  352.     Config2.DebugI = TRUE;
  353.     else
  354.     Config2.DebugI = FALSE;
  355. }
  356.  
  357. int DebugLClicked( void )
  358. {
  359.     if ( CompilerGadgets[11]->Flags & GFLG_SELECTED )
  360.     Config2.DebugL = TRUE;
  361.     else
  362.     Config2.DebugL = FALSE;
  363. }
  364.  
  365. int DynamicClicked( void )
  366. {
  367.     if ( CompilerGadgets[10]->Flags & GFLG_SELECTED )
  368.     Config2.DStack = TRUE;
  369.     else
  370.     Config2.DStack = FALSE;
  371. }
  372.  
  373. int ChipClicked( void )
  374. {
  375.     if ( LinkerGadgets[2]->Flags & GFLG_SELECTED )
  376.     Config2.Chip = TRUE;
  377.     else
  378.     Config2.Chip = FALSE;
  379. }
  380.  
  381. int CPUClicked( void )
  382. {
  383.     Config2.CPU = CompilerMsg.Code;
  384. }
  385.  
  386. int FPUClicked( void )
  387. {
  388.     Config2.FPU = CompilerMsg.Code;
  389. }
  390.  
  391. int DataClicked( void )
  392. {
  393.     Config2.Data = CompilerMsg.Code;
  394. }
  395.  
  396. int CodeClicked( void )
  397. {
  398.     Config2.Code = CompilerMsg.Code;
  399. }
  400.  
  401. int CallsClicked( void )
  402. {
  403.     Config2.RCalls = CompilerMsg.Code;
  404. }
  405.  
  406. int InlineClicked( void )
  407. {
  408.     if ( CompilerGadgets[6]->Flags & GFLG_SELECTED )
  409.     Config2.ICalls = TRUE;
  410.     else
  411.     Config2.ICalls = FALSE;
  412. }
  413.  
  414. int HunkCodeClicked( void )
  415. {
  416.     Config2.HunkCode = CompilerMsg.Code;
  417. }
  418.  
  419. int Gadget70Clicked( void )
  420. {
  421.     if ( CompilerGadgets[7]->Flags & GFLG_SELECTED )
  422.     Config2.CPP = TRUE;
  423.     else
  424.     Config2.CPP = FALSE;
  425. }
  426.  
  427. int ProtoClicked( void )
  428. {
  429.     if ( CompilerGadgets[8]->Flags & GFLG_SELECTED )
  430.     Config2.Proto = TRUE;
  431.     else
  432.     Config2.Proto = FALSE;
  433. }
  434.  
  435. int ProfileClicked( void )
  436. {
  437.     Config2.Prof = CompilerMsg.Code;
  438. }
  439.  
  440. int FragmentClicked( void )
  441. {
  442.     if ( LinkerGadgets[5]->Flags & GFLG_SELECTED )
  443.     Config2.Frag = TRUE;
  444.     else
  445.     Config2.Frag = FALSE;
  446. }
  447.  
  448. int UnixLibClicked( void )
  449. {
  450.     if ( LinkerGadgets[6]->Flags & GFLG_SELECTED )
  451.     Config2.Unix = TRUE;
  452.     else
  453.     Config2.Unix = FALSE;
  454. }
  455.  
  456.  
  457.  
  458. /****************************************************************************
  459. ***                                      ***
  460. ***    Gestion de la fenêtre Main Options                  ***
  461. ***                                      ***
  462. ****************************************************************************/
  463.  
  464. void ProjectCloseGenOpt( BOOL use ) {
  465.     if ( GenOptWnd ) {
  466.     RemWinC( GenOptWnd );
  467.     CloseGenOptWindow( );
  468.     if ( use )
  469.     {
  470.         if ( memcmp( &Config , &Config2 , sizeof( struct CompilerOpts ) ) ) {
  471.         saved = FALSE;
  472.         compilall = TRUE;
  473.         link = TRUE;
  474.         memcpy( &Config , &Config2 , sizeof( struct CompilerOpts ) );
  475.         MakeOptions();
  476.         RemoveAssign( );
  477.         MakeAssign( );
  478.         }
  479.     }
  480.     }
  481. }
  482.  
  483. int GenTypeClicked( void )
  484. {
  485.     Config2.ObjType = GenOptMsg.Code;
  486. }
  487.  
  488. int VerClicked( void )
  489. {
  490.     Config2.Version[0] = GenOptMsg.Code+'0';
  491. }
  492.  
  493. int RevClicked( void )
  494. {
  495.     Config2.Version[2] = GenOptMsg.Code+'0';
  496. }
  497.  
  498. int GenOptUseClicked( void )
  499. {
  500.     ProjectCloseGenOpt( TRUE );
  501. }
  502.  
  503. int GenOptCancelClicked( void )
  504. {
  505.     ProjectCloseGenOpt( FALSE );
  506. }
  507.  
  508. int GenOptVanillaKey( void )
  509. {
  510.     switch( GenOptMsg.Code )
  511.     {
  512.       case 't':
  513.       case 'T':
  514.     if ( isupper( GenOptMsg.Code ) )
  515.         Config2.ObjType --;
  516.     else
  517.         Config2.ObjType ++;
  518.     if ( Config2.ObjType <0 )
  519.         Config2.ObjType = 2;
  520.     if ( Config2.ObjType >2 )
  521.         Config2.ObjType = 0;
  522.     GT_SetGadgetAttrs( GenOptGadgets[0] , GenOptWnd , NULL , GTCY_Active , Config2.ObjType , TAG_DONE );
  523.     break;
  524.       case 'v':
  525.       case 'V':
  526.     if ( isupper( (int)GenOptMsg.Code ) )
  527.     {
  528.         if ( Config2.Version[0] > '0' )
  529.         Config2.Version[0] --;
  530.     }
  531.     else
  532.     {
  533.         if ( Config2.Version[0] < '9' )
  534.         Config2.Version[0] ++;
  535.     }
  536.     GT_SetGadgetAttrs( GenOptGadgets[1] , GenOptWnd , NULL , GTSL_Level , Config2.Version[0]-'0' , TAG_DONE );
  537.     break;
  538.       case 'R':
  539.       case 'r':
  540.     if ( isupper( (int)GenOptMsg.Code ) )
  541.     {
  542.         if ( Config2.Version[2] > '0' )
  543.         Config2.Version[2] --;
  544.     }
  545.     else
  546.     {
  547.         if ( Config2.Version[2] < '9' )
  548.         Config2.Version[2] ++;
  549.     }
  550.     GT_SetGadgetAttrs( GenOptGadgets[2] , GenOptWnd , NULL , GTSL_Level , Config2.Version[2]-'0' , TAG_DONE );
  551.     break;
  552.       case 'u':
  553.       case 'U':
  554.     ProjectCloseGenOpt( TRUE );
  555.     break;
  556.       case 'a':
  557.       case 'A':
  558.     ProjectCloseGenOpt( FALSE );
  559.     break;
  560.     }
  561. }
  562.  
  563. int ProjectMainOpt( void )
  564. {
  565.     if ( !GenOptWnd ) {
  566.     if ( !OpenGenOptWindow( ) ) {
  567.         GT_SetGadgetAttrs( GenOptGadgets[0] , GenOptWnd , NULL , GTCY_Active , Config.ObjType , TAG_DONE );
  568.         GT_SetGadgetAttrs( GenOptGadgets[1] , GenOptWnd , NULL , GTSL_Level , Config.Version[0]-'0' , TAG_DONE );
  569.         GT_SetGadgetAttrs( GenOptGadgets[2] , GenOptWnd , NULL , GTSL_Level , Config.Version[2]-'0' , TAG_DONE );
  570.         memcpy( &Config2 , &Config , sizeof( struct CompilerOpts ) );
  571.         AddWinC( GenOptWnd , HandleGenOptIDCMP );
  572.     }
  573.     } else {
  574.     WindowToFront( GenOptWnd );
  575.     ActivateWindow( GenOptWnd );
  576.     }
  577. }
  578.  
  579. /****************************************************************************
  580. ***                                      ***
  581. ***    Gestion de la fenêtre DirSet                      ***
  582. ***                                      ***
  583. ****************************************************************************/
  584.  
  585. int ProjectDirectory( void )
  586. {
  587.     if ( !DirSetWnd ) {
  588.     SSource = strdup( SourceDir );
  589.     SDest = strdup( DestDir );
  590.     SInclude = strdup( IncludeDir );
  591.     SLib = strdup( LibDir );
  592.     SObj = strdup( ObjDir );
  593.     SDICE = strdup( DICEDir );
  594.     SEdit = strdup( Editor );
  595.     if ( !OpenDirSetWindow( ) ) {
  596.         GT_SetGadgetAttrs( DirSetGadgets[6] , DirSetWnd , NULL , GTTX_Text , (long)SourceDir , TAG_DONE );
  597.         GT_SetGadgetAttrs( DirSetGadgets[7] , DirSetWnd , NULL , GTTX_Text , (long)DestDir , TAG_DONE );
  598.         GT_SetGadgetAttrs( DirSetGadgets[8] , DirSetWnd , NULL , GTTX_Text , (long)IncludeDir , TAG_DONE );
  599.         GT_SetGadgetAttrs( DirSetGadgets[9] , DirSetWnd , NULL , GTTX_Text , (long)LibDir , TAG_DONE );
  600.         GT_SetGadgetAttrs( DirSetGadgets[10] , DirSetWnd , NULL , GTTX_Text , (long)ObjDir , TAG_DONE );
  601.         GT_SetGadgetAttrs( DirSetGadgets[11] , DirSetWnd , NULL , GTTX_Text , (long)DICEDir , TAG_DONE );
  602.         GT_SetGadgetAttrs( DirSetGadgets[13] , DirSetWnd , NULL , GTTX_Text , (long)AutoDir , TAG_DONE );
  603.         AddWinC( DirSetWnd , HandleDirSetIDCMP );
  604.     }
  605.     } else {
  606.     WindowToFront( DirSetWnd );
  607.     ActivateWindow( DirSetWnd );
  608.     }
  609. }
  610.  
  611. /****************************************************************************
  612. ***                                      ***
  613. ***    Gestion de la fenêtre Compiler Options                  ***
  614. ***                                      ***
  615. ****************************************************************************/
  616.  
  617. int ProjectCompilerOpt( void )
  618. {
  619.     if ( !CompilerWnd ) {
  620.     if ( !OpenCompilerWindow( ) ) {
  621.         memcpy( &Config2 , &Config , sizeof( struct CompilerOpts ) );
  622.         GT_SetGadgetAttrs( CompilerGadgets[0] , CompilerWnd , NULL , GTMX_Active , (long)Config2.CPU , TAG_DONE );
  623.         GT_SetGadgetAttrs( CompilerGadgets[1] , CompilerWnd , NULL , GTMX_Active , (long)Config2.FPU , TAG_DONE );
  624.         GT_SetGadgetAttrs( CompilerGadgets[2] , CompilerWnd , NULL , GTMX_Active , (long)Config2.Code , TAG_DONE );
  625.         GT_SetGadgetAttrs( CompilerGadgets[3] , CompilerWnd , NULL , GTMX_Active , (long)Config2.Data , TAG_DONE );
  626.         GT_SetGadgetAttrs( CompilerGadgets[4] , CompilerWnd , NULL , GTMX_Active , (long)Config2.RCalls , TAG_DONE );
  627.         GT_SetGadgetAttrs( CompilerGadgets[5] , CompilerWnd , NULL , GTMX_Active , (long)Config2.HunkCode , TAG_DONE );
  628.         GT_SetGadgetAttrs( CompilerGadgets[6] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.ICalls , TAG_DONE );
  629.         GT_SetGadgetAttrs( CompilerGadgets[7] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.CPP , TAG_DONE );
  630.         GT_SetGadgetAttrs( CompilerGadgets[8] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.Proto , TAG_DONE );
  631.         GT_SetGadgetAttrs( CompilerGadgets[9] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.Resident , TAG_DONE );
  632.         GT_SetGadgetAttrs( CompilerGadgets[10] ,CompilerWnd , NULL , GTCB_Checked , (long)Config2.DStack , TAG_DONE );
  633.         GT_SetGadgetAttrs( CompilerGadgets[11] ,CompilerWnd , NULL , GTCB_Checked , (long)Config2.DebugL , TAG_DONE );
  634.         GT_SetGadgetAttrs( CompilerGadgets[12] , CompilerWnd , NULL , GTMX_Active , (long)Config2.Prof , TAG_DONE );
  635.         AddWinC( CompilerWnd , HandleCompilerIDCMP );
  636.     }
  637.     } else {
  638.     WindowToFront( CompilerWnd );
  639.     ActivateWindow( CompilerWnd );
  640.     }
  641. }
  642.  
  643. int CompilerVanillaKey( long code ) {
  644.     switch( code ) {
  645.     case 'U':
  646.     case 'u':
  647.         CompilerUseClicked();
  648.         break;
  649.     case 'a':
  650.     case 'A':
  651.         CompilerCancelClicked();
  652.         break;
  653.     case '0':
  654.     case '2':
  655.     case '3':
  656.         code -= '0';
  657.         if ( code )
  658.         code--;
  659.         Config2.CPU = code;
  660.         GT_SetGadgetAttrs( CompilerGadgets[0] , CompilerWnd , NULL , GTMX_Active , (long)Config2.CPU , TAG_DONE );
  661.         break;
  662.     case 'n':
  663.     case 'N':
  664.         code = '5';
  665.     case '6':
  666.         code -= '5';
  667.     case '8':
  668.         if ( code > 1 )
  669.         code = 2;
  670.         Config2.FPU = code;
  671.         GT_SetGadgetAttrs( CompilerGadgets[1] , CompilerWnd , NULL , GTMX_Active , (long)Config2.FPU , TAG_DONE );
  672.         break;
  673.     case 's':
  674.     case 'S':
  675.         code = 'k';
  676.     case 'L':
  677.     case 'l':
  678.         Config2.Code = tolower(code) - 'k';
  679.         GT_SetGadgetAttrs( CompilerGadgets[2] , CompilerWnd , NULL , GTMX_Active , (long)Config2.Code , TAG_DONE );
  680.         break;
  681.     case 'M':
  682.     case 'm':
  683.         code = 'e' - 1;
  684.     case 'e':
  685.     case 'E':
  686.         Config2.Data = tolower( code ) - 'e' + 1;
  687.         GT_SetGadgetAttrs( CompilerGadgets[3] , CompilerWnd , NULL , GTMX_Active , (long)Config2.Data , TAG_DONE );
  688.         break;
  689.     case 'r':
  690.     case 'R':
  691.         code = 's';
  692.     case 't':
  693.     case 'T':
  694.         Config2.RCalls = tolower( code ) - 's';
  695.         GT_SetGadgetAttrs( CompilerGadgets[4] , CompilerWnd , NULL , GTMX_Active , (long)Config2.RCalls , TAG_DONE );
  696.         break;
  697.     case 'o':
  698.     case 'O':
  699.         code = 'g';
  700.     case 'h':
  701.     case 'H':
  702.         code = tolower(code) - 'g';
  703.     case 'P':
  704.     case 'p':
  705.         if ( code > 1 )
  706.         code = 2;
  707.         Config2.HunkCode = code;
  708.         GT_SetGadgetAttrs( CompilerGadgets[5] , CompilerWnd , NULL , GTMX_Active , (long)Config2.HunkCode , TAG_DONE );
  709.         break;
  710.     case 'i':
  711.     case 'I':
  712.         Config2.ICalls = 1 - Config2.ICalls ;
  713.         GT_SetGadgetAttrs( CompilerGadgets[6] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.ICalls , TAG_DONE );
  714.         break;
  715.     case '+':
  716.         Config2.CPP = 1 - Config2.CPP ;
  717.         GT_SetGadgetAttrs( CompilerGadgets[7] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.CPP , TAG_DONE );
  718.         break;
  719.     case 'f':
  720.     case 'F':
  721.         Config2.Proto = 1 - Config2.Proto ;
  722.         GT_SetGadgetAttrs( CompilerGadgets[8] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.Proto , TAG_DONE );
  723.         break;
  724.     case 'c':
  725.     case 'C':
  726.         Config2.Resident = 1 - Config2.Resident ;
  727.         GT_SetGadgetAttrs( CompilerGadgets[9] , CompilerWnd , NULL , GTCB_Checked , (long)Config2.Resident , TAG_DONE );
  728.         break;
  729.     case 'd':
  730.     case 'D':
  731.         Config2.DStack = 1 - Config2.DStack ;
  732.         GT_SetGadgetAttrs( CompilerGadgets[10] ,CompilerWnd , NULL , GTCB_Checked , (long)Config2.DStack , TAG_DONE );
  733.         break;
  734.     case '1':
  735.         Config2.DebugL = 1 - Config2.DebugL;
  736.         GT_SetGadgetAttrs( CompilerGadgets[11] ,CompilerWnd , NULL , GTCB_Checked , (long)Config2.DebugL , TAG_DONE );
  737.         break;
  738.     case 'g':
  739.     case 'G':
  740.         code = 'x';
  741.     case 'y':
  742.     case 'Y':
  743.         code = tolower( code ) - 'x';
  744.     case 'b':
  745.     case 'B':
  746.         if ( code > 1 )
  747.         code = 2;
  748.         Config2.Prof = code;
  749.         GT_SetGadgetAttrs( CompilerGadgets[12] , CompilerWnd , NULL , GTMX_Active , (long)Config2.Prof , TAG_DONE );
  750.         break;
  751.     }
  752. }
  753.  
  754. /****************************************************************************
  755. ***                                      ***
  756. ***    Gestion de la fenêtre Linker Options                  ***
  757. ***                                      ***
  758. ****************************************************************************/
  759.  
  760. int ProjectLinkerOpt( void ) {
  761.     if ( !LinkerWnd ) {
  762.     if ( !OpenLinkerWindow( ) ) {
  763.         memcpy( &Config2 , &Config , sizeof( struct CompilerOpts ) );
  764.         GT_SetGadgetAttrs( LinkerGadgets[2] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Chip , TAG_DONE );
  765.         GT_SetGadgetAttrs( LinkerGadgets[3] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Hunk , TAG_DONE );
  766.         GT_SetGadgetAttrs( LinkerGadgets[4] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.DebugI , TAG_DONE );
  767.         GT_SetGadgetAttrs( LinkerGadgets[5] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Frag , TAG_DONE );
  768.         GT_SetGadgetAttrs( LinkerGadgets[6] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Unix , TAG_DONE );
  769.         AddWinC( LinkerWnd , HandleLinkerIDCMP );
  770.     }
  771.     } else {
  772.     WindowToFront( LinkerWnd );
  773.     ActivateWindow( LinkerWnd );
  774.     }
  775. }
  776.  
  777. int LinkerVanillaKey( long code ) {
  778.     switch( code ) {
  779.     case 'U':
  780.     case 'u':
  781.         LinkerUseClicked();
  782.         break;
  783.     case 'a':
  784.     case 'A':
  785.         LinkerCancelClicked();
  786.         break;
  787.     case 'I':
  788.     case 'i':
  789.         Config2.Chip = 1-Config2.Chip;
  790.         GT_SetGadgetAttrs( LinkerGadgets[2] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Chip , TAG_DONE );
  791.         break;
  792.     case 'H':
  793.     case 'h':
  794.         Config2.Hunk = 1-Config2.Hunk;
  795.         GT_SetGadgetAttrs( LinkerGadgets[3] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Hunk , TAG_DONE );
  796.         break;
  797.     case 'd':
  798.     case 'D':
  799.         Config2.DebugI = 1-Config2.DebugI;
  800.         GT_SetGadgetAttrs( LinkerGadgets[4] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.DebugI , TAG_DONE );
  801.         break;
  802.     case 'F':
  803.     case 'f':
  804.         Config2.Frag = 1-Config2.Frag;
  805.         GT_SetGadgetAttrs( LinkerGadgets[5] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Frag , TAG_DONE );
  806.         break;
  807.     case 'l':
  808.     case 'L':
  809.         Config2.Unix = 1-Config2.Unix;
  810.         GT_SetGadgetAttrs( LinkerGadgets[6] , LinkerWnd , NULL , GTCB_Checked , (long)Config2.Unix , TAG_DONE );
  811.         break;
  812.     }
  813. }
  814.  
  815. /****************************************************************************
  816. ***                                      ***
  817. ***    Gestion de la fenêtre Screen Options                  ***
  818. ***                                      ***
  819. ****************************************************************************/
  820.  
  821. int ProjectScreenOpt( void )
  822. {
  823.     ScreenPrefs( ScreenTags );
  824. }
  825.  
  826. /****************************************************************************
  827. ***                                      ***
  828. ***    Gestion de la fenêtre Editor Options                  ***
  829. ***                                      ***
  830. ****************************************************************************/
  831.  
  832. int ProjectEditorOpt( void ) {
  833.   struct FileRequester *fr;
  834.   char *name;
  835.  
  836.     if ( fr = AskFile( Editor , "Select editor executable" , "" ) ) {
  837.     name = PathName( fr->rf_Dir , fr->rf_File );
  838.     ReplaceChar( &Editor , name );
  839.     free( name );
  840.     FreeAslRequest(fr);
  841.     }
  842. }
  843.  
  844. /****************************************************************************
  845. ***                                      ***
  846. ***    Actions pour lire et ecrire les options               ***
  847. ***                                      ***
  848. ****************************************************************************/
  849.  
  850. BOOL LoadOptions( struct IFFHandle *iff ) {
  851. struct StoredProperty *buf;
  852. char *data;
  853.  
  854.     PropChunk( iff , ID_PREF , ID_COPT );
  855.     PropChunk( iff , ID_PREF , ID_DIRS );
  856.     PropChunk( iff , ID_PREF , ID_WPOS );
  857.     PropChunk( iff , ID_PREF , ID_LOPT );
  858.     StopOnExit( iff , ID_PREF , ID_FORM );
  859.  
  860.     LoadScreenTags( iff );
  861.  
  862.     ParseIFF( iff , IFFPARSE_SCAN );
  863.     if ( buf = FindProp( iff , ID_PREF , ID_DIRS ) ) {
  864.     data = (char *)buf->sp_Data;
  865.     ChangeDICEDir( data );
  866.     data += strlen(data)+1;
  867.     ReplaceChar( &SourceDir , data );
  868.     data += strlen(data)+1;
  869.     ReplaceChar( &DestDir , data );
  870.     data += strlen(data)+1;
  871.     ReplaceChar( &IncludeDir , data );
  872.     data += strlen(data)+1;
  873.     ReplaceChar( &LibDir , data );
  874.     data += strlen(data)+1;
  875.     ReplaceChar( &ObjDir , data );
  876.     data += strlen(data)+1;
  877.     ReplaceChar( &Editor , data );
  878.     data += strlen(data)+1;
  879.     if ( data < (char *)buf->sp_Data + buf->sp_Size )
  880.         ReplaceChar( &AutoDir , data );
  881.     } else {
  882.     Message( StrMessages[ MSG_MESSAGE_CANT_OPTION ] , StrMessages[MSG_MESSAGE_CONTINUE] );
  883.     return( FALSE );
  884.     }
  885.     if ( buf = FindProp( iff , ID_PREF , ID_WPOS ) ) {
  886.     ProjectTop = ((UWORD *)buf->sp_Data)[0];
  887.     ProjectLeft = ((UWORD *)buf->sp_Data)[1];
  888.     ProjectWidth = ((UWORD *)buf->sp_Data)[2];
  889.     ProjectHeight = ((UWORD *)buf->sp_Data)[3];
  890.     MessTop = ((UWORD *)buf->sp_Data)[4];
  891.     MessLeft = ((UWORD *)buf->sp_Data)[5];
  892.     MessWidth = ((UWORD *)buf->sp_Data)[6];
  893.     MessHeight = ((UWORD *)buf->sp_Data)[7];
  894.     }
  895.     if ( buf = FindProp( iff , ID_PREF , ID_COPT ) ) {
  896.     memcpy( &Config , buf->sp_Data , buf->sp_Size );
  897.     MakeOptions( );
  898.     }
  899.     if ( buf = FindProp( iff , ID_PREF , ID_LOPT ) ) {
  900.     ReplaceChar( &ParmsLine , buf->sp_Data );
  901.     }
  902.     RemoveAssign( );
  903.     MakeAssign( );
  904.     return( TRUE );
  905. }
  906.  
  907. void SaveOptions( struct IFFHandle *iff ) {
  908.     PushChunk( iff , ID_PREF , ID_FORM , IFFSIZE_UNKNOWN );
  909.  
  910.     SaveScreenTags( iff );
  911.  
  912.     PushChunk( iff , ID_PREF , ID_COPT , IFFSIZE_UNKNOWN );
  913.     WriteChunkBytes( iff , &Config , sizeof(struct CompilerOpts) );
  914.     PopChunk( iff );
  915.  
  916.     PushChunk( iff , ID_PREF , ID_LOPT , strlen( ParmsLine )+1 );
  917.     WriteChunkBytes( iff , ParmsLine , strlen( ParmsLine ) + 1 );
  918.     PopChunk( iff );
  919.  
  920.     PushChunk( iff , ID_PREF , ID_DIRS , IFFSIZE_UNKNOWN );
  921.     WriteChunkBytes( iff , DICEDir , strlen(DICEDir)+1 );
  922.     WriteChunkBytes( iff , SourceDir , strlen(SourceDir)+1 );
  923.     WriteChunkBytes( iff , DestDir , strlen(DestDir)+1 );
  924.     WriteChunkBytes( iff , IncludeDir , strlen(IncludeDir)+1 );
  925.     WriteChunkBytes( iff , LibDir , strlen(LibDir)+1 );
  926.     WriteChunkBytes( iff , ObjDir , strlen(ObjDir)+1 );
  927.     WriteChunkBytes( iff , Editor , strlen(Editor)+1 );
  928.     WriteChunkBytes( iff , AutoDir , strlen(AutoDir)+1 );
  929.     PopChunk( iff );
  930.  
  931.     PushChunk( iff , ID_PREF , ID_WPOS , 16 );
  932.     WriteChunkBytes( iff , &ProjectTop , 2 );
  933.     WriteChunkBytes( iff , &ProjectLeft , 2 );
  934.     WriteChunkBytes( iff , &ProjectWidth , 2 );
  935.     WriteChunkBytes( iff , &ProjectHeight , 2 );
  936.     WriteChunkBytes( iff , &MessTop , 2 );
  937.     WriteChunkBytes( iff , &MessLeft , 2 );
  938.     WriteChunkBytes( iff , &MessWidth , 2 );
  939.     WriteChunkBytes( iff , &MessHeight , 2 );
  940.     PopChunk( iff );
  941.  
  942.     PopChunk( iff );
  943. }
  944.  
  945. void LoadPrefs( void )
  946. {
  947.   struct IFFHandle *iff;
  948.  
  949.     if ( iff = OpenIffFile( "ENV:project.prefs" , MODE_OLDFILE ) ) {
  950.     LoadOptions( iff );
  951.     CloseIffFile( iff );
  952.     }
  953. }
  954.  
  955. void SavePrefs( void )
  956. {
  957.   struct IFFHandle *iff;
  958.  
  959.     if ( iff = OpenIffFile( "ENVARC:project.prefs" , MODE_NEWFILE ) ) {
  960.     SaveOptions( iff );
  961.     CloseIffFile( iff );
  962.     }
  963.     if ( iff = OpenIffFile( "ENV:project.prefs" , MODE_NEWFILE ) ) {
  964.     SaveOptions( iff );
  965.     CloseIffFile( iff );
  966.     }
  967. }
  968.  
  969.